package com.cxm.report.model.criteria;

import com.cxm.report.model.IReport;
import com.cxm.report.util.DateUtil;
import lombok.Setter;
import org.springframework.util.StringUtils;

import java.util.Date;

/**
 * @author scl.BlueOcean
 * @version 1.0
 * @date 2018年07月06 10:52
 * @description
 */
@Setter
public class ReportFilter {
    //报告类型
    private String scopeType;
    private int type;
    private String begin;
    private String end;

    public String getBegin() {
        Date now = new Date();
        if (begin == null || "".equals(begin)|| DateUtil.compare(begin,now) > 0){
            begin = DateUtil.getDefaultFormat().format(now);
        }
       /* if (begin == null || "".equals(begin)|| DateUtil.compare(begin,new Date()) >= 0){
            begin = DateUtil.getFutureDay(DateUtil.getDefaultFormat(),-1);
        }*/
        return begin;
    }

    public String getEnd() {
        Date now = new Date();
        if (end == null || "".equals(end)||DateUtil.compare(end,now)>0){
            end = DateUtil.getDefaultFormat().format(now);
        }
        /*if (end == null || "".equals(end)||DateUtil.compare(end,new Date())>=0){
            end = DateUtil.getFutureDay(DateUtil.getDefaultFormat(),-1);
        }*/
        return end;
    }

    public String getScopeType() {
        return StringUtils.hasText(scopeType) ? scopeType : IReport.ScopeType.DAY;
    }
    public int getType() {
        return type;
//        return StringUtils.hasText(type) ? type : IReport.Type.BRAND.getType();
    }
    public boolean isConatainCurrentDay(){
        return DateUtil.compare(getEnd(),DateUtil.currentDay())==0;
    }
}
